from django.http import HttpResponseRedirect, HttpResponse
from django.template import RequestContext
from django.shortcuts import render_to_response

from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required

from rango.view.category import get_category_list

@login_required
def profile(request):
    context = RequestContext(request)
    context_dict = {'cat_list': get_category_list()}
    user = User.objects.get(username=request.user)
    
    try:
        user_profile = UserProfile.objects.get(user=u)
    except:
        user_profile = None
        
    context_dict['user'] = user
    context_dict['userprofile'] = user_profile
    return render_to_response('rango/profile.html', context_dict, context)